<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>添加管理员</title>
<link href="__PUBLIC__/admin/css/xc.min.css" rel="stylesheet" type="text/css" />
<link href="__PUBLIC__/admin/css/xc.admin.css" rel="stylesheet" type="text/css" />
<link href="__PUBLIC__/lib/iconfont/iconfont.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="__PUBLIC__/admin/js/jquery.min.js"></script>
<script type="text/javascript" src="__PUBLIC__/lib/layer/layer.js"></script>
<script type="text/javascript" src="__PUBLIC__/admin/js/xc.js"></script> 
<script type="text/javascript" src="__PUBLIC__/admin/js/xc.admin.js"></script>
<script type="text/javascript" src="__PUBLIC__/admin/js/common-1.0.js"></script> 
</head>
<body>
<div class="pd-20">
  <form action="" method="post" class="form form-horizontal" id="myform">
    <div class="row cl">
      <label class="form-label col-3"><span class="c-red">*</span>姓名账号：</label>
      <div class="formControls col-8">
        <input type="text" id="uname" name="uname" class="input-text" value="{$list.ad_name}" readonly placeholder="请输入个人姓名">
      </div>
    </div>
    <div class="row cl">
      <label class="form-label col-3"><span class="c-red">*</span>手机号：</label>
      <div class="formControls col-8">
        <input type="text" id="phone" name="phone" class="input-text" value="{$list.ad_phone}" placeholder="请输入常用手机号">
      </div>
    </div>
    <div class="row cl">
      <label class="form-label col-3"><span class="c-red">*</span>邮箱号：</label>
      <div class="formControls col-8">
        <input type="text" id="email" name="email" class="input-text" value="{$list.ad_email}" placeholder="请输入常用邮箱号">
      </div>
    </div>
    <div class="row cl">
      <label class="form-label col-3"><span class="c-red">*</span>更改密码：</label>
      <div class="formControls col-8">
        <input type="text" id="pwds" name="pwds" class="input-text"  placeholder="无需更改请为空">
      </div>
    </div>
    <div class="row cl">
      <div class="col-9 col-offset-3">
        <input type="hidden" id="aid" name="aid" value="{$list.ad_id}">
        <button type="button" id="sub" name="sub" class="btn btn-primary radius" onClick="checkSubmit()"><i class='Hui-iconfont'>&#xe632;</i> 保存</button>
        <input class="btn btn-default radius" type="button" onClick="layer_close();" value="取消"/>
      
        <br/><span style="font-size:12px; color:#f00">注：信息修改成功，下次登录成功生效</span>
      </div>
    </div>
    
  </form>
</div>
<script type="text/javascript">
//按回车件触发提交
document.onkeydown=function(event){
	var e = event || window.event || arguments.callee.caller.arguments[0];
	if(e && e.keyCode==13){ // enter 键
		checkSubmit();
	}
}; 
//提交数据
function checkSubmit()
{
	var uname = $.trim($('#uname').val());
	var phone = $.trim($('#phone').val());
	var email = $.trim($('#email').val());
	if(uname == ''){
		layer.msg('个人姓名不能为空!', {icon: 2});
		return false;
	}if(phone == ''){
		layer.msg('手机号不能为空!', {icon: 2});
		return false;
	}if(!checkMobile(phone)){
		layer.msg('手机号码格式不正确!', {icon: 2});
		return false;
	}if(email == ''){
		layer.msg('邮箱不能为空!', {icon: 2});
		return false;
	}if(!checkEmail(email)){
		layer.msg('邮箱格式不正确!', {icon: 2});
		return false;
	}
	$.ajax({
		type : 'post',
		url : "{:U('Index/adminEdit')}",
		data : $("#myform").serialize(),
		dataType : 'json',
		success : function(res){
			if(res.status == 1){
				layer.msg(res.msg,{icon:1},function(){
					// 先获取窗口索引，才能关闭窗口  
					var index = parent.layer.getFrameIndex(window.name);
				    parent.layer.close(index);
				});
			}else{
				layer.msg(res.msg, {icon: 2});
			}
		},
		error : function(XMLHttpRequest, textStatus, errorThrown) {
			layer.alert('网络失败，请刷新页面后重试',{icon:2});
		}
	})
}
</script>
</body>
</html>